<template>
  <div class="my_container">
    <div style="height: 30px" />
    <van-cell-group>
      <van-field label="服务器：" v-model="address" />
    </van-cell-group>
    <div style="height: 30px" />
    <van-button type="primary" @click="save" size="large">保存</van-button>
  </div>
</template>
<script setup lang="ts">
import { STORAGE_KEY, getValue, setValue } from '@/utils/localStorage';
import { ref } from 'vue';
import { showSuccessToast } from 'vant';
import router from '@/router';
import { useUserStore } from '@/stores/userInfo';

const address = ref();
address.value = getValue(STORAGE_KEY.MY_SERVER);
const save = () => {
  const store = useUserStore();
  store.set_address(address.value);
  showSuccessToast('设置成功');
  router.push('/login');
};
</script>
